notebook: Fix up ref counting
authorMatthias Clasen <mclasen@redhat.com>
Thu, 21 Feb 2019 04:02:39 +0000 (23:02 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 21 Feb 2019 05:31:17 +0000 (00:31 -0500)
We need to keep a ref to the page objects.

gtk/gtknotebook.c

index c9ea3bf72bdbd6a59f3a2c175440d1b10fa1e923..34ee81199c71fa328b2710d56ab3684d9bbd58f0 100644 (file)
@@ -4216,7 +4216,7 @@ gtk_notebook_insert_notebook_page (GtkNotebook *notebook,
   if ((position < 0) || (position > nchildren))
     position = nchildren;
 
-  priv->children = g_list_insert (priv->children, page, position);
+  priv->children = g_list_insert (priv->children, g_object_ref (page), position);
 
   if (position < nchildren)
     sibling = GTK_NOTEBOOK_PAGE_FROM_LIST (g_list_nth (priv->children, position))->tab_widget;
@@ -4305,6 +4305,7 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
                                gint         position)
 {
   GtkNotebookPage *page;
+  int ret;
 
   page = g_object_new (GTK_TYPE_NOTEBOOK_PAGE,
                        "child", child,
@@ -4312,7 +4313,11 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook,
                        "menu", menu_label,
                        NULL);
 
-  return gtk_notebook_insert_notebook_page (notebook, page, position);
+  ret = gtk_notebook_insert_notebook_page (notebook, page, position);
+
+  g_object_unref (page);
+
+  return ret;
 }
 
 static gboolean